//
//  BInviteManagerDetailVC.m
//  Distributor
//
//  Created by 主事丫环 on 2019/5/14.
//  Copyright © 2019 主事丫环. All rights reserved.
//

#import "BInviteManagerDetailVC.h"

@interface BInviteManagerDetailVC ()
@property (weak, nonatomic) IBOutlet UIImageView *shopImage;
@property (weak, nonatomic) IBOutlet UIImageView *guanliyuanImage;
@property (weak, nonatomic) IBOutlet UILabel *shopName;
@property (weak, nonatomic) IBOutlet UILabel *lainxirenLB;
@property (weak, nonatomic) IBOutlet UILabel *lianxiPhonelb;
@property (weak, nonatomic) IBOutlet UILabel *locationLb;
@property (weak, nonatomic) IBOutlet UILabel *xiangxiAddreslb;
@property(nonatomic,strong)NSMutableDictionary *mudic;

@property(nonatomic,copy)NSString *phone;


@end

@implementation BInviteManagerDetailVC
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:NO];
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:NO];

}
- (void)leftClick{
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    [super leftClick];
}
- (IBAction)returnaction:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)shengjiquanxina:(UIButton *)sender {
    //升级权限
    if ([[self.mudic objectForKey:@"level"] integerValue] == 2) {
        ShowToastWithText(@"该店铺已经是管理员");
        return;
    }
    kWeakSelf;
    
    UIAlertController *alerrtcon = [UIAlertController alertControllerWithTitle:@"本店所属区域已有管理员" message:@"确定更改？" preferredStyle:(UIAlertControllerStyleAlert)];
    UIAlertAction *quxioa = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    
    UIAlertAction *queding = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        NSMutableDictionary *param = [NSMutableDictionary dictionaryWithCapacity:1];
        param[@"id"] = [_mudic objectForKey:@"agent_id"];

        [NetWorkTool POST:setPower param:param success:^(id dic) {
            KMyLog(@"dsfdsfsdf%@",dic);
            ShowToastWithText(@"设置成功");
            [self request];
        } other:^(id dic) {
            ShowToastWithText(dic[@"msg"]);
        } fail:^(NSError *error) {
            
        } needUser:YES];
        
    }];
    
    [alerrtcon addAction:quxioa];
    [alerrtcon addAction:queding];
    [self presentViewController:alerrtcon animated:YES completion:nil];
    
   
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.mudic = [NSMutableDictionary dictionaryWithCapacity:1];
    [self request];
    // Do any additional setup after loading the view from its nib.
}
-(void)request{
   
    
    NSMutableDictionary *param = [NSMutableDictionary dictionaryWithCapacity:1];
    param[@"id"] =NOTNIL(self.shopid);

    [NetWorkTool POST:getAgentShopInfo param:param success:^(id dic) {
        KMyLog(@"dsfdsfsdf%@",dic);
        self.mudic = [dic objectForKey:@"data"];
        if ([[self.mudic objectForKey:@"shop_image"] hasPrefix:@"http"]) {
            [self.shopImage sd_setImageWithURL:[NSURL URLWithString:[self.mudic objectForKey:@"shop_image"]] placeholderImage:defaultImg];
        }else{
            sdimg(self.shopImage, [self.mudic objectForKey:@"shop_image"]);
            
        }
        
        self.shopName.text = [NSString stringWithFormat:@"%@",[self.mudic objectForKey:@"shop_name"]];
        self.lainxirenLB.text = [NSString stringWithFormat:@"%@",[self.mudic objectForKey:@"person"]];
        self.phone = [NSString stringWithFormat:@"%@",[self.mudic objectForKey:@"shop_phone"]];
        self.locationLb.text = [NSString stringWithFormat:@"%@",[self.mudic objectForKey:@"area"]];
        self.xiangxiAddreslb.text = [NSString stringWithFormat:@"%@",[self.mudic objectForKey:@"shop_address"]];

        
    } other:^(id dic) {
        ShowToastWithText(dic[@"msg"]);
    } fail:^(NSError *error) {
        
    } needUser:YES];
    
    
}

- (IBAction)call:(id)sender {
    
    [HFTools callMobilePhone:self.phone];
    
}

@end
